<template>
    <div class="page__all">

        <div class="user__card">
            <div class="user__row">
                <div class="user__info">
                    <div class="user__avatar">
                        <img :src="userinfo.avatar?userinfo.avatar:defult_avatar" alt="">
                    </div>
                    <div class="user__name">
                        <span>{{ userinfo.username }}</span>
                    </div>
                </div>
                <div class="edit__info__btn" @click="edit_userinfo">
                    编辑资料
                </div>
            </div>

        </div>

        <div class="page__body">
            <div class="body__title">我的作品</div>
            <div class="body__list">

                <GenarateRecord></GenarateRecord>
            </div>
        </div>


        <UserInfoDialog
        @cancel="cancel"
        :visible="isVisible"
        :instance="userinfo"
        :defult_avatar="defult_avatar"
        ></UserInfoDialog>
    </div>
</template>
           
<script setup>
    import { ref, onMounted } from "vue"
    import avatar_png from '@/assets/image/avatar.png'
    import GenarateRecord from './userinfo/GenarateRecord.vue'
    import UserInfoDialog from './userinfo/UserInfoDialog.vue'
    import { useUserStore } from '@/stores/user'

    const userStore = useUserStore()

    const defult_avatar = ref(avatar_png)
    const isVisible = ref(false)


    const userinfo = ref(userStore.userinfo)

    function edit_userinfo(){
        isVisible.value = true
    }
    function cancel(){
        isVisible.value = false
    }

    onMounted(()=>{
    
    })
    
</script>
<style scoped lang="scss">
.page__all{
    width: 100%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    .user__card{
        width: 100%;
        height: 170px;
        background: url('@/assets/image/user_back.png');
        border-radius: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        .user__row{
            width: 100%;
            height: 170px;
            padding: 0 90px;
            display: flex;
            justify-content:space-between;
            align-items: center;
            .user__info{
                width: 50%;
                min-width: 280px;
                height: 120px;
                // border: 1px solid red;
                display: flex;
                // justify-content: center;
                align-items: center;
                .user__avatar{
                    img{
                        width: 120px;
                        height: 120px;
                        border: 2px solid #fff;
                        border-radius: 60px;
                        overflow: hidden;
                        object-fit: cover;
                    }
                    
                }
                .user__name{
                    margin-left: 50px;
                    span{
                        font-size: 28px;
                        color: #fff;
                    }
                }
            }
            .edit__info__btn{
                cursor: pointer;
                width: 120px;
                height: 40px;
                border: 2px solid #fff;
                border-radius: 20px;
                display: flex;
                justify-content: center;
                align-items: center;
                color: #fff;
                font-size: 13px;
            }
            .edit__info__btn:hover{
                color: var(--wchime-color-highlight);
            }
        }
    }

    .page__body{
        height: calc(100% - 170px);
        .body__title{
            display: flex;
            padding: 10px 0 0 10px ;
            font-size: 30px;
            height: 60px;

        }
        .body__list{
            height: calc(100% - 60px);
            overflow: auto;
        }

    }

}

</style>